#include"bits/stdc++.h"
using namespace std;
int a[110][110];
int main()
{
int i,j,i1,j1,i2,j2,n,m;
char b[110][110];
cin>>n>>m;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
cin>>b[i][j];
if(b[i][j]=='*')
{
i1=i-1;
i2=i+1;
j1=j-1;
j2=j+1;
a[i1][j1]++;
a[i2][j1]++;
a[i1][j2]++;
a[i2][j2]++;
a[i][j1]++;
a[i][j2]++;
a[i1][j]++;
a[i2][j]++;
}
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
if(b[i][j]=='*')
{
cout<<b[i][j];
}
else
{
cout<<a[i][j];
}
}
cout<<endl;
}
}
